<?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::prefix('v1')->namespace('V1')->name('api.v1.')->group(function () {

    Route::get('time', 'IndexController@time');
    Route::get('client-config', 'IndexController@clientConfig');
    Route::get('upgrade', 'IndexController@upgrade');
    Route::get('app-resource', 'IndexController@appResource');
    Route::post('client-catch-log', 'IndexController@clientCatchLog');
    Route::post('client-log', 'IndexController@clientLog');
    Route::post('sync-node', 'IndexController@syncNode');
    Route::get('p', 'IndexController@p');
    Route::get('notice', 'IndexController@notice');
    Route::get('config/{channel}/appid', 'IndexController@configAppAppid');
    Route::get('redirect', 'IndexController@redirect')->name('index.redirect');
    // 平台通知
    Route::any('platform-notify/{action}', 'PlatformNotifyController@index')->where('action', '\w+');

    // 客服消息回复通知
    Route::any('kf/notify53', 'KfController@notify53');

    // 验证码
    Route::prefix('sms')->group(function () {
        Route::post('code', 'SmsController@sendCode')->middleware('throttle:10,1');
    });

    // 登录
    Route::post('login/{channel}', 'LoginController@index')->where('channel', '\w+');
    Route::post('user/logout', 'UserController@logout');

    // 支付回调
    Route::prefix('order')->group(function () {
        Route::any('return/{channel}/{payChannelId}', 'OrderNotifyController@return')->name('order.return');
        Route::any('notify/{channel}/{payChannelId}', 'OrderNotifyController@notify')->name('order.notify');
    });
    // 权益回调
    Route::prefix('withdraw-order')->group(function () {
        Route::any('notify/{channel}/{payChannelId}', 'WithdrawNotifyController@notify')->name('withdrawOrder.notify');
    });
    // 需要身份验证
    Route::middleware('auth:sanctum')->group(function () {

        Route::post('login/refresh-session', 'LoginController@refreshSession');
        Route::prefix('user')->group(function() {
            Route::get('', 'UserController@info');
            Route::post('bind-mobile', 'UserController@bindMobile');
            Route::post('real-name', 'UserController@realName');
            Route::post('bind-third/{channel}', 'UserController@bindThird');
            Route::get('alipay-info-str', 'UserController@getAlipayInfoStr');
            Route::post('destroy-apply', 'UserController@destroyApply');
            Route::post('destroy-cancel', 'UserController@destroyCancel');
        });

        Route::post('order', 'OrderController@store');
        Route::post('withdraw', 'WithdrawController@store');
        // 活动
        Route::prefix('activity')->group(function() {
            Route::get('task-type-14', 'ActivityController@taskType14');
            Route::post('task-type-14', 'ActivityController@taskType14GetAward');
        });

        Route::post('cdkey', 'CdkeyController@store');
    });
});
